<?php
defined('_JEXEC') or die;

class TravelTableTour extends JTable
{
	function __construct(&$db){
		parent::__construct('#__travel_tours', 'id', $db);
	}
	
	/**
	 * Override Function bind
	 * bind custom field value not in xml file
	 */
	public function bind($array, $ignore = array())
	{	
		if(is_array($array['catsid']))
			$array['catsid'] = implode(',', $array['catsid']);
		
		/* Get proper HTML-code for HTML-encoded field by using JREQUEST_ALLOWHTML*/
		//$data 	= JRequest::getVar( 'jform', '', 'post', 'array', JREQUEST_ALLOWHTML );//
		
		$data	= JRequest::getVar('jform');
		
		foreach($data as $key=>$value){
			if(is_array($value)){
				$data[$key] = json_encode($value);
			}
		} 
		$array					= array_merge($data,$array);
		$array['created_date'] 	= JFactory::getDate()->toMySQL();
		
		return parent::bind($array, $ignore);
	}
}